﻿@using Entidades.Sistema.Produccion
@using Entidades.Sistema.Venta

@{
    Html.EnableClientValidation();
    Html.EnableUnobtrusiveJavaScript();
}  

@Html.DevExpress().GridView(
settings =>
{
    settings.Name = "masterGrid";
    settings.KeyFieldName = "IdProduccionProducto";
    settings.CallbackRouteValues = new { Controller = "DiagramacionProduccion", Action = "EditProduccionProductosPartial" };
    settings.SettingsEditing.BatchUpdateRouteValues = new { Controller = "DiagramacionProduccion", Action = "EditProduccionProductosUpdatePartial" };
    settings.SettingsEditing.Mode = GridViewEditingMode.Batch;
    settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
            
    settings.Columns.Add("Producto.IdProducto").ReadOnly = true;
    settings.Columns.Add("Producto.Nombre").EditFormSettings.Visible = DefaultBoolean.False;
    settings.Columns.Add("CantidadDemanda").EditFormSettings.Visible = DefaultBoolean.False;
    settings.Columns.Add("CantidadExedente");
    settings.Columns.Add("Total").EditFormSettings.Visible = DefaultBoolean.False;

    settings.SettingsDetail.AllowOnlyOneMasterRowExpanded = true;
    settings.SettingsDetail.ShowDetailRow = true;    
    settings.SetDetailRowTemplateContent(c =>
    {  
        ViewContext.Writer.Write("<h4>Empleados Asignados:</h4>");
        Html.RenderAction("EditProduccionProductosDetallePartial", new { IdProduccionProducto = DataBinder.Eval(c.DataItem, "Producto.IdProducto") });        
    });

    //settings.PreRender = (sender, e) =>
    //{
    //    ((MVCxGridView)sender).DetailRows.ExpandAllRows();
    //};
           
}).Bind(Model).GetHtml()

